/**
 * @file ngmessagequeue.h
 * @author Suk Robert Koh (srkoh87z@gmail.com)
 *
 * @brief NGMessageQueue class provides a thread-safe queue for NGMessage type
 */

#ifndef NGMESSAGEQUEUE_H_
#define NGMESSAGEQUEUE_H_

#include <pthread.h>
#include <queue>
#include "ngmessage.h"

/**
 * @class	NGMessageQueue	Thread-safe queue for NGMessage type
 */
class NGMessageQueue
{
public:
	NGMessageQueue();
	virtual ~NGMessageQueue();

	int size();
	void clear();
	void remove();
	void push(NGMessage *);
	NGMessage *pop();
	NGMessage *peek();

private:
	std::queue<NGMessage *> queue;					/** STL queue object */
#ifdef WIN32
	CRITICAL_SECTION mutex;							/** Critical Section for sync on Windows platform */
#else
	pthread_mutex_t mutex;							/** Mutex for sync on Linux platform*/
#endif
};

#endif /* NGMESSAGEQUEUE_H_ */
